package com.User.mapper;

import com.User.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface UserMapper extends BaseMapper<User> {
    @Select("SELECT * FROM user WHERE email = #{email}")
    User findByEmail(String email);
    @Select("SELECT * FROM user WHERE username = #{username}")
    User findByUserame(String username);
    @Insert("INSERT INTO user(username, password, email) VALUES (#{username}, #{password}, #{email})")
    int registerUser(String username, String password, String email);
    @Select("SELECT LAST_INSERT_ID()")
    int lastInsertId();
    @Update("UPDATE user SET headSculpture = #{fileName} WHERE id = #{userId}")
    void updateUserHeadSculpture(Integer userId, String fileName);
}
